#!/bin/bash
# author: mmatczuk

function printinfo {
  echo ;echo --- USE: $(basename "${0}") \{x86 \| x86_64\}
}

# getopt...
arch=""
case ${1} in
  "x86") arch="x86";;
  "x86_64") arch="x86_64";;
  *) printinfo; exit -1
esac

cd $(dirname "${0}")
repo="$(pwd)/REPO"

# SWT
echo --- SWT
mvn install:install-file -DgroupId=org.eclipse -DartifactId=swt -Dversion=3.4 -Dpackaging=jar -Dfile="${repo}/swt-3.4/swt-3.4-gtk-linux-${arch}/swt.jar"

# JADE
echo --- JADE
mvn install:install-file -DgroupId=jade -DartifactId=commons-codec -Dversion=1.3 -Dpackaging=jar -Dfile="${repo}/jade-3.6.1/commons-codec/commons-codec-1.3.jar"
mvn install:install-file -DgroupId=jade -DartifactId=http -Dversion=3.6.1 -Dpackaging=jar -Dfile="${repo}/jade-3.6.1/http.jar"
mvn install:install-file -DgroupId=jade -DartifactId=iiop -Dversion=3.6.1 -Dpackaging=jar -Dfile="${repo}/jade-3.6.1/iiop.jar"
mvn install:install-file -DgroupId=jade -DartifactId=jade -Dversion=3.6.1 -Dpackaging=jar -Dfile="${repo}/jade-3.6.1/jade.jar"
mvn install:install-file -DgroupId=jade -DartifactId=jadeTools -Dversion=3.6.1 -Dpackaging=jar -Dfile="${repo}/jade-3.6.1/jadeTools.jar"

# OpenGL
echo --- OpenGL
mvn install:install-file -DgroupId=net.java.dev.jogl -DartifactId=jogl -Dversion=1.1.1 -Dpackaging=jar -Dfile="${repo}/jogl-1.1.1/jogl-1.1.1-linux-${arch}/jogl.jar"
mvn install:install-file -DgroupId=net.java.dev.gluegen -DartifactId=gluegen-rt -Dversion=1.1.1 -Dpackaging=jar -Dfile="${repo}/jogl-1.1.1/jogl-1.1.1-linux-${arch}/gluegen-rt.jar"

echo --- feed /usr/lib
sudo cp ${repo}/jogl-1.1.1/jogl-1.1.1-linux-${arch}/*.so /usr/lib
sudo chmod 644 /usr/lib/libgluegen-rt.so /usr/lib/libjogl.so /usr/lib/libjogl_awt.so


